<?php

namespace common\logics;

use Yii;
use common\helpers\Url;
use common\models\group\GroupUser;

/**
 * This is the model class for table "{{%group}}".
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class MineGroupLogic extends \common\models\group\Group {

    public function fields() {
        return [
            'id',
            'name',
            'thumb',
            'description',
        ];
    }

    public static function mine($uid) {
        $query = static::find()->active(static::STATUS_ACTIVE);
        $query->innerJoinWith('leaguers u', false);
        $query->andWhere(['!=', 'u.type', GroupUser::TYPE_BLACK]);
        $query->andWhere(['!=', 'u.user_id', $uid]);
        return $query->all();
    }

}
